function [y_predict,accuracy] = SVM(train_data,train_labels,test_data,test_labels,Default)

train_labels(train_labels~=0)=1;
test_labels(test_labels~=0)=1;

predictions=[];
labels=[];
errors=[];
scores=[];
if Default
    tic
    load("SVMModel.mat");
    toc
else
    cvp = cvpartition(train_labels, 'KFold', 5);
    BestModel = fitcsvm(train_data, train_labels, 'KernelFunction', 'gaussian', ...
        'KernelScale','auto', 'Standardize', true,...
        'HyperparameterOptimizationOptions',struct('Optimizer','gridsearch','MaxObjectiveEvaluations',100,'NumGridDivisions',200,'CVPartition',cvp), ...
        'OptimizeHyperparameters','auto');
    save("SVMModel",'BestModel');
end
[y_predict]=predict(BestModel,test_data);
accuracy=sum(test_labels==y_predict)./length(test_labels);
error = zeros(length(test_data),1);
index = y_predict~=test_labels;
error(index) = 1;
output = table(test_data,test_labels,y_predict,error);
filename = 'SVM.xlsx';
writetable(output,filename,'Sheet',1,'Range','A1')
end